home *** CD-ROM | disk | FTP | other *** search
- #
- ## MPW Script for removing VMS style version numbers from file
- ## names. By Godfrey DiGiorgi, Apple Computer, 16MAR92
- #
- # Description:
- # Given a folder of files with ';<number>' extensions, create
- # and execute a command file to rename them, eliminating
- # the extensions.
- #
- # Limitation:
- # If the stripped version of a filename will conflict with another
- # stripped filename, the file will not be renamed. This will happen
- # in version-extension number order, ie:
- # given: this.foo;1 this.foo;2 this.foo;3
- # execute this script
- # result: this.foo this.foo;2 this.foo;3
- #
- # Usage:
- # 0-Put this file into your "{Tools}" folder in the MPW Shell folder
- # 1-Set your working folder to the folder of files
- # that needs to have the ';<num>' ending stripped with the
- # MPW 'Directory' command or menu.
- # 2-Execute this file from the Worksheet
- #
- # Comments:
- # I leave the file 'namechange' in your MPW Shell directory so that
- # you can open it and see exactly what file was renamed what according
- # to the MPW 'Rename' command.
- #
- # Enjoy! -gdg
- #
- ## set shell variable - don't exit script on errors
- set exit 0
- ## get rid of old namechange command file
- del "{MPW}namechange" ≥≥ "{Worksheet}"
- ## assemble command file
- for F in `files -f -s -o` ## list all files, no folders, no headers, full path
- echo -n "rename -c " >> "{MPW}namechange"
- quote -n "{F}" >> "{MPW}namechange" ## filenames need quoting
- echo -n " " >> "{MPW}namechange"
- quote "{F}" >> "{MPW}namechange"
- end
- ## edit command file ##
- open -t "{MPW}namechange" ## open file as target
- find • "{MPW}namechange" ## go to top of file
- ## replace all occurences of ';<num>' where <num> is a single digit
- ## (you will need to add another '?' character if these are 2-digit)
- replace -c ∞ /";"?"∂'∂n"/ "∂'∂n" "{MPW}namechange"
- ## close command file with save
- close -y "{MPW}namechange"
- ## execute commands
- "{MPW}namechange"
- ## reset shell variable
- set exit 1
-